package com.zyg.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.zyg.pojo.Claee;

import com.zyg.pojo.Hostel;
import com.zyg.pojo.Major;
import com.zyg.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentMapper extends BaseMapper<Student> {

    @Select(" select  *  from student")
    List<Student> getStudentList();

    @Override
    @Select("select student_id,student_num,student_name,birthday,claee_id,hostel_id,major_id from student ${ew.customSqlSegment}")
    @Results({
            @Result(property = "studentId", column = "student_id"),
            @Result(property = "studentNum", column = "student_num"),
            @Result(property = "studentName", column = "student_name"),
            @Result(property = "birthday", column = "birthday"),
            @Result(property = "claee", column = "claee_id", javaType = Claee.class,
                    one = @One(select = "com.zyg.dao.ClaeeMapper.getClaeeById")),

            @Result(property = "hostel", column = "hostel_id", javaType = Hostel.class,
                    one = @One(select = "com.zyg.dao.HostelMapper.getHostelById")),

            @Result(property = "major", column = "major_id", javaType = Major.class,
                    one = @One(select = "com.zyg.dao.MajorMapper.getMajorById"))
    })
    List<Student> selectList(IPage<Student> page, @Param(Constants.WRAPPER) Wrapper<Student> queryWrapper);


}
